09. Going Beyond

Single Controller Option

In the previous two parts, we built our controller as an outer loop computing velocity commands from position information and an inner loop computing attitude/thrust commands from velocity information. This was the same approach that was used in the controls project.

Here we will just introduce the idea of a different structure to the controller. We have not provided example code for this structure, this is food for thought for those of you who want to explore other control structures and see how they might behave differently on a real platform.

Instead of building it as two parts, it is possible to build the entire controller as one piece:

attitude_cmd = KpPos * (pos_cmd - pos) + KpVel * (vel_cmd - vel)

If we are not flying a trajectory, we set vel_cmd = 0, which means that we are constantly damping our control based on how fast we are currently traveling. This structure ends up being a little more like a PD controller on position, but we are still directly measuring velocity instead of differentiating position. Note that with this structure, we can't directly limit the velocity command that is created, we can only limit the attitude command.

For this one, we won't be walking through what the solution looks like directly, but rather leaving it up to you to play around with the controller and see what happens!

For those who are very ambitious, can you think of different control structures you could use? The Crazyflie can be quite forgiving, so give it a try and see how it works out!